﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.GuaZhiDuanLianService;

namespace CommunitySystem
{
    public partial class GuaZhiDuanLianDateWindow : ChildWindow
    {
        public DateTime? Dt = null;
        private string IDS = "";
        private int JiHuaID = 0;
        private GuaZhiDuanLianServiceClient Client1 =
            new GuaZhiDuanLianServiceClient();
        public GuaZhiDuanLianDateWindow(string ids,int jihuaid)
        {
            InitializeComponent();
            IDS = ids;
            JiHuaID = jihuaid;
            Client1.GuaZhiJieShuCompleted += new EventHandler<GuaZhiJieShuCompletedEventArgs>(Client1_GuaZhiJieShuCompleted);
        }

        
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(riqi.Text) || Convert.ToDateTime(riqi.Text) == Convert.ToDateTime("1900-01-01"))
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请填写结束日期！");
                return;
            }
            Dt = Convert.ToDateTime(riqi.Text);
            if(MessageBox.Show("确定结束挂职锻炼吗？","提示",MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                Client1.GuaZhiJieShuAsync(IDS, Dt, JiHuaID);
            }
        }

        void Client1_GuaZhiJieShuCompleted(object sender, GuaZhiJieShuCompletedEventArgs e)
        {
            this.DialogResult = true;
        }
    }
}
